\section{Basic Text Manipulation}

For the next two videos, we will be talking through the basics of manipulating text and mathematics using \LaTeX. This video will focus on modifying the text portion of the document.

The first place we can modify the text is in the document class declaration. Inside of these square brackets, you can put optional arguments. You can set the standard font size to be 10, 11, or 12 point font. The default is 10 point, which I think is the best. But if you want to use a larger font, you can.

This isn't the only way we can impact the size of the font. This just sets the default font size. When you're inside document, there are nine different font sizes you can choose from.

\begin{center}
  \fbox{\includegraphics[width=0.85\linewidth]{img-2-1}}
\end{center}

There are two ways to use these commands. The first is to use it like a switch. \Large After you type in the appropriate command, you will have switched over to that font size until you switch it back. This can be good if you want to be in a particular font size for a long time. \normalsize However, most of the time you are just changing the font for just a few words. In this case, I recommend surrounding the text with curly brackets and putting the font modifier at the beginning of those brackets. It's still acting as a switch, but you're also creating a {\Large limited scope} in which that switch is being applied. I recommend this approach because it more closely resembles how we use curly brackets to group things together with other commands in \LaTeX. But it's ultimately up to you.

If these font sizes are not good enough for you, you can also look into the \href{https://ctan.org/pkg/extsizes}{\texttt{extsizes}} package and the \href{https://ctan.org/pkg/anyfontsize}{\texttt{anyfontsize}} package. But the odds are good you really won't need them.

The next set of text modifications are the font styles of \textbf{bold}, \textit{italicized}, and \uline{underlined} fonts. We use these by typing the appropriate command and encapsulating the text you want modified inside of the curly brackets. Notice that this is different from what we used for the font sizes. Font size changes are like a switch, whereas these are more like functions. We are applying a font modifier to a specific set of text. This is useful because it also allows us to stack these modifiers on top of each other.

\begin{center}
  \fbox{\includegraphics[width=0.85\linewidth]{img-2-2}}
\end{center}

This last example is worth looking at a little more closely. Notice that each opening bracket has a corresponding closing bracket. And inside each set of brackets there is a completely meaningful \LaTeX{} expression. If you fail to properly open and close your brackets, \LaTeX{} will complain at you when you try to compile your file. Sometimes, missing brackets can be very difficult to find. If you compile your file frequently, you will have fewer places to look to try to spot your errors.

There's a little bit of a warning that comes with the underlining. For individual words it works fine, but the default underlining command for \LaTeX{} doesn't know how to break across lines very well. If you need to underline a longer string of text, you should use the \href{http://ctan.mirrors.hoobly.com/macros/latex/contrib/ulem/ulem.pdf}{\texttt{ulem}} package. In the preamble, include this package and then use \verb|\uline| instead of \verb|\underline|.

\begin{center}
  \fbox{\includegraphics[width=0.95\linewidth]{img-2-3}}
\end{center}

The \texttt{ulem} package also has other features, such as \uuline{double underlining} and \uwave{wavy underlining}, but you can explore these on your own.

If you are using font styles to emphasize certain words or phrases, you might want to use \emph{text emphasis}. This tells \LaTeX\ that you want the text emphasized, but it will choose how to do it depending on the surrounding context. This is probably the best choice for any time you are working with multiple environments, such as when you're writing definitions or theorems, and it's probably not a bad habit to get into in general.

\begin{center}
  \fbox{\includegraphics[width=0.95\linewidth]{img-2-4}}
\end{center}

\LaTeX\ also gives you a set of options for changing the font itself. There are three basic font families: Roman, sans serif, and typewriter. The default is Roman, which is good enough for almost everything. I will use the typewriter font when I need a \texttt{monospaced} look. Notice that these are applied like functions and not as switches.

\begin{center}
  \fbox{\includegraphics[width=0.85\linewidth]{img-2-4a}}
\end{center}

The next type of text modifier that most people look for is alignment. The default behavior of \LaTeX\ is to stretch the text out so that it fills the entire space between the margins. This is sometimes called ``full justification.'' Alternate alignment modes no longer attempt to do that, which will give your text ragged edges.

To center the text, put it between a \verb|\begin{center}| and \verb|\end{center}|. To left-justify the text, put it between a \verb|\begin{flushleft}| and \verb|\end{flushleft}|. When you \mbox{do this}, the text does not stretch out to fill the space in between the margins. To right-justify the text, put it between a \verb|\begin{flushright}| and \verb|\end{flushright}|.

\begin{center}
  \fbox{\includegraphics[width=0.95\linewidth]{img-2-5}}
\end{center}

When you're in these alternate alignment modes, you can use a double backslash to start a new line. You can add extra spacing by putting in a measurement inside of square brackets immediately after the double backslash. This example shows you how to get one and two blank lines. Don't worry too much about what \verb|\baselineskip| means for now. 

\begin{center}
  \fbox{\includegraphics[width=0.85\linewidth]{img-2-6}}
\end{center}

\LaTeX\ automatically indents new paragraphs. New paragraphs happen when you have a blank line of code in your document. If you wanted to skip the indentation of a particular paragraph, you can use the \verb|\noindent| command at the beginning of that paragraph. If you wanted to change the indentation of the entire file, you would need to modify the indent size either in the preamble or at the beginning of the document. Here's how that command looks for a 1 cm indentation: \verb|\setlength{\parindent}{1cm}|. You can use several different units in \LaTeX, but we will won't focus on that.

\begin{center}
  \fbox{\includegraphics[width=0.4\linewidth]{img-2-7}}
\end{center}

\setlength{\parindent}{3cm}

Technically, you can reset this length all throughout the file. You can change the indentation of a single paragraph by changing the length of \verb|\parindent| just before the paragraph, and then change it back afterwards. However, this can make the text look very awkward and it isn't something that you would want to do in practice. Putting the change in the preamble communicates that you intend the change to apply to the entire document.

\setlength{\parindent}{15pt}

It's worth taking a moment to understand what the \verb|\setlength| command is doing. In the background, \LaTeX\ is doing a lot of work with the dimensions of different aspects of the text. Almost every aspect of the text is controlled by boxes that have various dimensions on them. To get a sense of this, here is a diagram that shows you all of the dimensions required just to establish the basic structures of how the text fits on a page. The \verb|\parindent| value is one of the many measurements that \LaTeX\ uses, and the \verb|\setlength| command is just redefining that value to whatever you want it to be. There's a lot more that can be said about these distances, but you can go for a long time without actually needing to worry about any of it.

\begin{center}
  \fbox{\includegraphics[width=0.95\linewidth]{img-2-8}}
\end{center}


And this will take care of most of the things you'll need to do with your text. In the next video, we'll start talking about how to handle mathematical symbols.